home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Installation Tools & Overlays 2002 November
/
SGI IRIX Installation Tools & Overlays 2002 November - Disc 4.iso
/
dist
/
cluster_admin.idb
/
usr
/
cluster
/
bin
/
ClusterDiags.z
/
ClusterDiags
Wrap
Text File
|
2002-10-15
|
7KB
|
273 lines
#!/usr/sbin/perl
#
# Copyright (C) 1998-2000, Silicon Graphics, Inc.
# All Rights Reserved.
#
# UNPUBLISHED -- Rights reserved under the copyright laws of the United
# States. Use of a copyright notice is precautionary only and does not
# imply publication or disclosure.
#
# THIS SOFTWARE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF
# SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR
# DISCLOSURE IS STRICTLY PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN
# PERMISSION OF SILICON GRAPHICS, INC.
#
# U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
# Use, duplication or disclosure by the Government is subject to
# restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph
# (c)(1)(ii) of the Rights in Technical Data and Computer Software
# clause at DFARS 252.227-7013 and/or in similar or successor clauses
# in the FAR, or the DOD or NASA FAR Supplement. Unpublished-- rights
# reserved under the copyright laws of the United States.
# Contractor/manufacturer is Silicon Graphics, Inc.,
# 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
#
$LibDiagsPath = "/var/cluster/ha/diags";
$DiagsPath = "/var/cluster/ha/diags";
require "$LibDiagsPath/libdiags.pl";
require "$DiagsPath/ConnectivityTests";
require "$DiagsPath/SerialTests";
require "$DiagsPath/ResourceTypeTests.pl";
require "$DiagsPath/ResourceGroupTests.pl";
require "$DiagsPath/FailoverPolicyTests.pl";
require "$DiagsPath/machine.pl";
sub Usage
{
print "USAGE: ClusterDiags\n";
print "\t{ {{_RESOURCE=<name>} _RESOURCE_TYPE=<type>} or\n";
print "\t _RESOURCE_GROUP=<group> }\n";
print "\t _FAILOVER_POLICY=<policy> }\n";
print "\t{_CONNECTIVITY=<true|false> or \n" ;
print "\t _SERIAL=<true|false>}\n";
print "\t_CLUSTER=<cluster name>\n";
print "\t_DESTRUCTIVE=<true|false>, default false\n";
print "\t_NUM_MACHINES=<n, n >=1 > _MACHINE_<n>=<name, n >= 0> ... \n";
print "\t_VERBOSE=<true|false>, default false\n";
exit(1);
}
sub ProcessArgs
{
local ($argi, $newargi, $return_value);
local ($i, @machinelist);
$return_value = $CD_SUCCESS;
&LogEntry();
if ($#ARGV < 0) {
&Usage();
}
# Default commands.
$ResourceType = ALL;
$Resource = ALL;
$TestOption = ResourceType;
$newargi = 0;
for ($argi = 0; $argi <= $#ARGV; $argi++) {
if ($ARGV[$argi] =~ /_RESOURCE_TYPE=(.*)/) {
$TestOption = ResourceType;
$ResourceType = $1;
$typeset = 1;
}elsif ($ARGV[$argi] =~ /_RESOURCE_GROUP=(.*)/) {
$TestOption = ResourceGroup;
$ResourceGroup = $1;
$grpset = 1;
}elsif ($ARGV[$argi] =~ /_FAILOVER_POLICY=(.*)/) {
$TestOption = FailoverPolicy;
$Policy = $1;
$polset = 1;
}elsif ($ARGV[$argi] =~ /_RESOURCE=(.*)/) {
$TestOption = Resource;
$Resource = $1;
$resset = 1;
}elsif ($ARGV[$argi] =~ /_CLUSTER=(.*)/) {
$Cluster = $1;
$cluset = 1;
}elsif ($ARGV[$argi] =~ /_CONNECTIVITY=(.*)/) {
if ($1 eq "true") {
$conset = 1;
$TestOption = Connectivity;
}
}elsif ($ARGV[$argi] =~ /_SERIAL=(.*)/) {
if ($1 eq "true") {
$serset = 1;
$TestOption = Serial;
}
}elsif ($ARGV[$argi] =~ /_VERBOSE=(.*)/) {
$verbose = 1;
}elsif ($ARGV[$argi] =~ /_DESTRUCTIVE=(.*)/) {
if ($1 eq "true") {
&Warning("Executing the tests in destructive mode");
# Global variable, used in the resource scripts.
$DESTRUCTIVE=1;
} else {
$DESTRUCTIVE=0;
}
}elsif ($ARGV[$argi] =~ /_MACHINE_(\d+)=(.*)/) {
$MachineList = 1;
$List[$1] = $2;
$macset = 1;
}elsif ($ARGV[$argi] =~ /_NUM_MACHINES=(.*)/) {
$num_machines = $1 - 1;
$MachineList = 1;
$macset = 1;
} else {
Usage();
} # end if ( ...
} # end for ( ...
# Check that we have the all arguments needed to fulfill the requrest
if ($conset && $serset) {
&Warning("you cannot choose both _CONNECTIVITY and _SERIAL");
&Usage();
}
if ($conset && $resset) {
&Warning("you cannot choose both _CONNECTIVITY and _RESOURCE");
&Usage();
}
if ($conset && $grpset) {
&Warning("you cannot choose both _CONNECTIVITY and _RESOURCE_GROUP");
&Usage();
}
if ($conset && $polset) {
&Warning("you cannot choose both _CONNECTIVITY and _FAILOVER_POLICY");
&Usage();
}
if ($conset && $typeset) {
&Warning("you cannot choose both _CONNECTIVITY and _RESOURCE_TYPE");
&Usage();
}
if (($resset) && (!$typeset)) {
&Warning("you must set both _RESOURCE and _RESOURCE_TYPE");
&Usage();
}
if (!$cluset) {
&Warning("you must supply the _CLUSTER parameter");
&Usage();
}
if (($typeset) && ($grpset)) {
&Warning("you cannot choose both _RESOURCE_TYPE and _RESOURCE_GROUP");
&Usage();
}
if ($typeset && $polset) {
&Warning("you cannot choose both _RESOURCE_TYPE and _FAILOVER_POLICY");
&Usage();
}
if ($grpset && $polset) {
&Warning("you cannot choose both _RESOURCE_GROUP and _FAILOVER_POLICY");
&Usage();
}
if (!$macset) {
$Local = 1;
} else {
if (scalar(@List) != $num_machines+1) {
&Warning("internal error: number of machines don't match, list = %d, number = %d",
scalar(@List),$num_machines+1);
&Usage();
}
}
return($return_value);
}
sub PerformTest {
local (@machines) = @_;
local ($machine);
local ($retv);
&LogEntry();
if ($TestOption eq Connectivity) {
$retv=&PerformConnectivityTests(@machines);
&ExitStatus($retv);
} elsif ($TestOption eq Serial) {
$retv=&PerformSerialTests(@machines);
&ExitStatus($retv);
} else {
foreach $machine (@machines) {
&Verbose("running %s test on node %s",
$TestOption,$machine);
# Always test the machine specification
if (!($retv=&PerformMachineTests($machine))) {
&ExitStatus($retv);
return ($retv);
}
if ($TestOption eq ResourceType) {
# The same tests handle both resources and resource types.
$retv=&PerformResourceTypesTests($machine);
} elsif ($TestOption eq ResourceGroup) {
$retv=&PerformResourceGroupTests($machine);
} elsif ($TestOption eq Resource) {
# The same tests handle both resources and resource types.
$retv=&PerformResourceTypesTests($machine,$Resource);
} elsif ($TestOption eq FailoverPolicy) {
$retv=&PerformFailoverPolicyTests($machine,$Resource);
} else {
&Warning("unknown action %s requested",$TestOption);
$retv=$CD_FAILURE;
}
}
}
return $retv;
}
# main:
#
#
# Before we do anything, set the global error counters etc
$CD_ERRNO=$CD_SUCCESS;
$CD_ERRCNT=0;
$CD_TESTCNT=0;
if (&ProcessArgs()) {
local ($retv)=$CD_SUCCESS;
# Generate a hash table of node to machine names
NodetoHostname();
if ($Local) {
if ($TestOption eq ResourceGroup) {
# run tests only for nodes in the AFD
@machinelist=GetMachinesinGroupAFD($ResourceGroup);
if (scalar(@machinelist) < 1) {
# error message already printed
&Debug("No machines found in AFD for resource group %s", $ResourceGroup);
$retv=$CD_FAILURE;
} else {
$retv=$CD_SUCCESS;
}
} else {
@machinelist=GetAllMachines();
}
if ($retv == $CD_SUCCESS) {
$retv=&PerformTest(@machinelist);
}
} else {
$retv=&PerformTest(@List);
}
&PrintStatus();
# Because the test use 1==success and 0==failure, which is opposite
# to normal scripting.
if ($CD_ERRNO == $CD_FAILURE) {
exit(1);
} else {
exit(0);
}
}